/*
 * =====================================================================================
 *
 *       Filename:  Vector.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  01/07/12 18:24:12
 *       Revision:  none
 *       Compiler:  g+=
 *
 *         Author:  LittleQ Su (), 98703060@nccu.edu.tw
 *        Company:  National Chengchi University, The Department of Computer Science
 *
 * =====================================================================================
 */
#ifndef __VECTOR_H__
#define __VECTOR_H__
#include "Headers.h"
#include "Exception.h"

using std::allocator;
using std::max;
using std::uninitialized_copy;
using std::uninitialized_fill;
using std::ptrdiff_t;

template <class T>
class Vector {
    public:
        // Type for internal usage
        typedef T* iterator;
        typedef std::size_t size_type;
        // Constructors & desctructors
        Vector() ;
        Vector(int) ;
        Vector(const Vector&) ;
        ~Vector() ;

        // member functions
        void insert(int, const T&) ;
        void erase(int) ;
        void swap( Vector& ) ;
        void clear() ;
        int size() const ;
        int capacity() const ;
        iterator begin() const;
        iterator end() const;

        // operator overloading
        T& operator[](int i) {
            _check_index(i);
            return _data[i];
        }
        const T& operator[](int i) const {
            _check_index(i);
            return _data[i];
        }
    private:
        int _elements_num;
        T *_data;
        T *_avail;
        T *_limit;

        std::allocator<T> _alloc;

        void _grow();
        void _check_index(int) const;

};
#endif

